package com.hbd.esdemo.handler;

import com.hbd.esdemo.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author bdhong
 */
@Slf4j
@ControllerAdvice
public class ExceptionHandle {


    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Result exceptionHandle(Exception e) {
        log.error(e.getMessage(), e);
        e.printStackTrace();
        return Result.buildFailure("系统内部异常：" + e.getMessage());
    }
}
